home *** CD-ROM | disk | FTP | other *** search
/ Aminet 23 / Aminet 23 (1998)(GTI - Schatztruhe)[!][Feb 1998].iso / Aminet / util / boot / speedychip.lha / speedychip.ASM < prev    next >
Assembly Source File  |  1997-11-13  |  3KB  |  121 lines

  1. ; speedychip.ASM  --  v1.0.6 5.11 1997
  2. ; Patch to speed up chipmem writeaccess on 060 CPUs.
  3. ; Tested with BLIZZARD 1260, Apollo 4060 and CS MK II 060.
  4. ; Written by Harry "Piru" Sintonen <sintonen@jyu.fi> (IRC: Piru).
  5. ; Copyright © 1997 Harry Sintonen. Freeware.
  6. ;
  7. ; This program was developed 22nd August while on IRC and was written
  8. ; using pico 2.9 ;) It was DCC'd on irc to Sly who compiled and tested
  9. ; it on his 1260. Also thanks a lot to Sly for sending me lots of 060
  10. ; MMU-list dumps... =) Thanks to Peeri for testing this on his A4000/060.
  11. ; Also thanks to Duken for testing this on A4000/CS060. 5.11: RobinC
  12. ; succesfully tested speedychip on his Blizzard 1260. Finally tests only
  13. ; for 060. RobinC compiled 1.0.6, thanks dude!-)
  14. ;
  15. ; This routine can be used for any purpose (for demos too, hehe:), but you
  16. ; should give me some credit... (or? I don't think this is unreasonable).
  17. ; Note that this patch needs to be started after SetPatch.
  18. ;
  19. ; Apparently daeron has made this before, but I wanted to see how much
  20. ; this speeds things up. I also wanted to learn something about 040/060
  21. ; MMU (I have 030). Yet one funny thing: I didn't use Amiga at all when I
  22. ; wrote this program:))
  23. ;
  24. ; There is program called SetCacheMode by Phase5. It can be used to change
  25. ; chip cachemode too, but with speedychip you don't need to worry about
  26. ; commandline arguments... ;) Anyways, speedychip doesn't base on
  27. ; SetCacheMode.
  28. ;
  29. ; Oh, and one thing: I take no responsibility for damages caused by these
  30. ; 1'n'0s... ;)
  31. ;
  32.  
  33.     include    "exec/types.i"
  34.     include    "exec/libraries.i"
  35.     include    "exec/execbase.i"
  36.     include    "exec/exec_lib.i"
  37.  
  38. call    MACRO
  39.     jsr    (_LVO\1,a6)
  40.     ENDM
  41.  
  42. Main    move.l    (4).w,a6
  43.     tst.b    (AttnFlags+1,a6) ; Test for 060 (bit 7)
  44.     bmi.b    .has_060p
  45.     moveq    #60,d0        ;)
  46.     rts
  47.  
  48. .has_060p
  49.     lea    (.gettcr,pc),a5
  50.     call    Supervisor
  51.     btst    #15,d0        ; E - Enable
  52.     bne.b    .mmu_enabled
  53.     moveq    #20,d0        ; 68060.library not loaded... (run SetPatch)
  54.     rts
  55.  
  56. .mmu_enabled
  57.     btst    #14,d0        ; P - Page Size
  58.     beq.b    .has4k        ; Must have 4k page size
  59.     moveq    #20,d0
  60.     rts
  61.  
  62. .has4k    call    Disable        ; no others messing around, please...
  63.  
  64.     lea    (.geturp,pc),a5
  65.     call    Supervisor
  66.     move.l    d0,a0        ; a0=array of 128 root-level table descriptors, 32mb each
  67.  
  68.     move.l    (a0),d0
  69.     and.w    #$FE00,d0
  70.     move.l    d0,a4        ; a4=array of 128 pointer table descriptors, 256k each
  71.  
  72.     moveq    #8-1,d3        ; Patch all page desciptors of first 8 table
  73. .mloop    move.l    (a4)+,d0    ; descriptors (8*256k=2m=size of chipmem)
  74.     bsr.b    .patch
  75.     dbf    d3,.mloop
  76.  
  77.     lea    (.flush,pc),a5    ; flush ATC & caches
  78.     call    Supervisor
  79.     call    CacheClearU    ; flush caches with OS too (just to be sure:)
  80.     call    Enable        ; and back...
  81.  
  82.     moveq    #0,d0        ; all ok!
  83.     rts
  84.  
  85. .patch    and.w    #$FE00,d0
  86.     move.l    d0,a0        ; a0=array of 64 page descriptors
  87.     moveq    #64-1,d1
  88. .ploop    move.l    (a0),d2
  89.     move.l    d2,d0
  90.     and.b    #%11,d0        ; get PDT
  91.     beq.b    .next        ; 00=invalid
  92.     cmp.b    #%10,d0        ; 10=indirect
  93.     beq.b    .next
  94.  
  95.     ; ok this is really it:
  96.  
  97.     or.b    #%1100000,d2    ; set cm (bits 5&6) to 11 (Cache-Inhibited, Imprecise exception model)
  98.     move.l    d2,(a0)
  99.  
  100. .next    addq.l    #4,a0
  101.     dbf    d1,.ploop
  102.     rts
  103.  
  104. .gettcr    dc.l    $4e7a0003    ;movec    tc,d0
  105.     nop
  106.     rte
  107.  
  108. .geturp    dc.l    $4e7a0806    ;movec    urp,d0
  109.     nop
  110.     rte
  111.  
  112. .flush    dc.w    $F518    ; PFLUSHA    flush the address translation cache
  113.     dc.w    $F4F8    ; CPUSHA BC    flush the caches into memory
  114.     dc.w    $F4D8    ; INVA  BC    invalidate the data and inst caches
  115.      nop
  116.     rte
  117.  
  118.     dc.b    '$VER: speedychip 1.0.6 (5.11.97)',0
  119.     dc.b    '$COPYRIGHT: Copyright © 1997 Harry "Piru" Sintonen <sintonen@jyu.fi>',10
  120.     dc.b    'Freeware.',0
  121.